// Copyright 2020 The Tilt Brush Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//      http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

Shader "Unlit/FullScreenOverlay"
{
  Properties
  {
    _Color ("Color", Color) = (1,1,1,1)
  }
  SubShader
  {
    Tags { "Queue"="Overlay-1" "RenderType"="Transparent" }
    ZTest Always
    ZWrite Off

    // Disable blending of alpha channel
    Blend SrcAlpha OneMinusSrcAlpha, Zero One

    Pass {
      CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag

        #include "UnityCG.cginc"

        struct appdata_t {
          float4 vertex : POSITION;

          UNITY_VERTEX_INPUT_INSTANCE_ID
        };

        struct v2f {
          float4 vertex : SV_POSITION;

          UNITY_VERTEX_OUTPUT_STEREO
        };

        uniform float4 _Color;

        v2f vert (appdata_t v)
        {
          v2f o;

          UNITY_SETUP_INSTANCE_ID(v);
          UNITY_INITIALIZE_OUTPUT(v2f, o);
          UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

          o.vertex = UnityObjectToClipPos(v.vertex);
          return o;
        }

        fixed4 frag (v2f i) : SV_Target
        {
          return _Color;
        }
      ENDCG
    }
  }
}
